<?php

ob_start('ob_gzhandler');
session_start();

include("./includes/settings.inc");
require("./includes/detections.inc");

compatdetect();

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<?xml-stylesheet type=\"text/css\" href=\"./CSS/comment-popup.css\"?>";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=$language?>">
<head>
<link rel="stylesheet" type="text/css" href="./CSS/comment-popup.css" />

<?php
if (!isset($_GET['action'])){
echo "<title>Reactie toevoegen.</title>\n";
echo "</head>\n";
echo "<body>\n";
echo "<h2>Reactie toevoegen.</h2>\n";
echo "<div class=\"italic\">U kunt BBcode gebruiken.</div>\n";
echo "<form action=\"submit.php\" method=\"post\">\n";
echo "Titel: <input type=\"text\" name=\"title\" size=\"52\" /><br /><br />\n";
echo "Bericht:<br />\n";
echo "<textarea name=\"message\" rows=\"10\" cols=\"45\"></textarea><br />\n";
echo "<input type=\"hidden\" name=\"forid\" value=\"$_GET[id]\" />\n";
echo "<input type=\"hidden\" name=\"action\" value=\"addcomment\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Toevoegen!\" />\n";
}

if ($_GET['action']=="edit"){
$res = mysql_query("SELECT * FROM enlight_comments WHERE id='$_GET[id]'");
$row = mysql_fetch_row($res);

$orgarray = array("'\<span class=\"bold\">(.*?)\</span\>'is", "'\<span class=\"italic\">(.*?)\</span\>'is", "'\<span class=\"underline\">(.*?)\</span\>'is", "'\<a href=\"(.*?)\"\>(.*?)\</a\>'i");

$replarray = array("[b]\\1[/b]", "[i]\\1[/b]", "[u]\\1[/u]", "[url=\"\\1\"]\\2[/url]");

$message = preg_replace($orgarray, $replarray, $row['5']); 

echo "<title>Reactie aanpassen.</title>\n";
echo "</head>\n";
echo "<body>\n";
echo "<h2>Reactie aanpassen.</h2>\n";
echo "<div class=\"italic\">U kunt BBcode gebruiken.</div>\n";
echo "<form action=\"submit.php\" method=\"post\">\n";
echo "Titel: <input type=\"text\" name=\"title\" size=\"52\" value=\"$row[4]\" /><br /><br />\n";
echo "Bericht:<br />\n";
echo "<textarea name=\"message\" rows=\"10\" cols=\"45\">$message</textarea><br />\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$_GET[id]\" />\n";
echo "<input type=\"hidden\" name=\"action\" value=\"editcomment\" />\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Aanpassen!\" />\n";
}

?>

</form>
</body>
</html>